# CMake 最低版本号要求
cmake_minimum_required (VERSION 2.8)

# 项目信息
project (utility)
set(SRC_FILE uuid.cpp)
set(CMAKE_CXX_STANDARD 11)
set (CMAKE_INCLUDE_CURRENT_DIR ON)

message("构建bat工程")

# 查找目录下的所有源文件
# 并将名称保存到 DIR_SRCS 变量
aux_source_directory(./${PROJECT_NAME} DIR_SRCS)
FILE(GLOB_RECURSE DIR_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}/${SRC_FILE})

foreach(src ${DIR_SRCS})
message("srcFile:" ${src})
endforeach(src ${Dir_srcs})

IF(${MSVC})
    SET (BOOST_ROOT "D:/local/boost_1_64_0")
    SET (BOOST_INCLUDEDIR "D:/local/boost_1_64_0")
    SET (BOOST_LIBRARYDIR "d:/boost_1_64_0/lib32-msvc-12.0")
    SET (BOOST_MIN_VERSION "1.64.0")
    # set (Boost_NO_BOOST_CMAKE ON)
elseif(${MINGW})
    SET (BOOST_ROOT "D:\\msys64\\mingw32")
    SET (BOOST_INCLUDEDIR "D:\\msys64\\mingw32\\include")
    SET (BOOST_LIBRARYDIR "D:\\msys64\\mingw32\\lib")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexec-charset=UTF-8")
    # set (Boost_NO_BOOST_CMAKE ON)
endif()

find_package(Boost COMPONENTS  filesystem program_options date_time  system REQUIRED)
if (NOT Boost_FOUND)
    message(FATAL_ERROR "Fatal error: Boost (version >= 1.55) required.")
else()
    message(STATUS "Setting up BOOST")
    message(STATUS " Includes - ${Boost_INCLUDE_DIRS}")
    message(STATUS " Library  - ${Boost_LIBRARY_DIRS}")
endif (NOT Boost_FOUND)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common)
include_directories(${BOOST_INCLUDEDIR})
link_directories(${Boost_LIBRARY_DIRS})
message(STATUS "Boostlib:" ${Boost_LIBRARIES})
message(STATUS "BoostlibDirs:" ${Boost_LIBRARY_DIRS})
if(${MINGW})
link_libraries(${Boost_LIBRARIES})
endif()

# 指定生成目标
add_executable(${PROJECT_NAME} ${RESOURCES} ${DIR_SRCS})
# SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:windows")

message("cxxFlags:" ${CMAKE_CXX_FLAGS_DEBUG} "\nlink:" ${CMAKE_EXE_LINKER_FLAGS_DEBUG} )
message("CMAKE_LINK_LIBRARY_FLAG:" ${CMAKE_LINK_LIBRARY_FLAG})